﻿using System;

namespace Vlog
{
	public class MsAccess
	{
		System.Data.OleDb.OleDbConnection m_connection = null;
		public MsAccess()
		{
			this.m_connection = new System.Data.OleDb.OleDbConnection();
			this.m_connection.ConnectionString = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ticker-2k.mdb";
			this.m_connection.Open();
		}

		public System.Data.OleDb.OleDbCommand MakeCommand(string queryString, params object[] paramList)
		{
			System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(queryString, this.m_connection);
			int count = 0;
			foreach (object param in paramList)
			{
				count++;
				if (param is DateTime || param is String)
				{
					command.Parameters.Add("@" + count, System.Data.OleDb.OleDbType.VarChar).Value = param;
				}
				else
				{
					command.Parameters.Add("@" + count, System.Data.OleDb.OleDbType.Integer).Value = param;
				}
			}
			return command;
		}
	}
}
